From: Felix Fietkau Date: Tue, 23 Aug 2022 21:11:28 +0000 (+0200) Subject: host: deal with host/peer null pointers in debug messages X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=7b7ac845c551015f63282162501525962daf4c71;p=project%2Funetd.git host: deal with host/peer null pointers in debug messages Signed-off-by: Felix Fietkau --- diff --git a/host.h b/host.h index bf61e75..985ac45 100644 --- a/host.h +++ b/host.h @@ -49,13 +49,20 @@ struct network_group { static inline const char *network_host_name(struct network_host *host) { + if (!host) + return "(none)"; + return host->node.key; } static inline const char *network_peer_name(struct network_peer *peer) { - struct network_host *host = container_of(peer, struct network_host, peer); + struct network_host *host; + + if (!peer) + return "(none)"; + host = container_of(peer, struct network_host, peer); return network_host_name(host); }